<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>注册</title>

<link rel="stylesheet"
	href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<script
	src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script
	src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
	$(function() {

		$("#nameinput").blur(
				function() {
					var name = $("#nameinput").val();
					//alert(name);
					$.ajax({

						type : "post",
						url : "/vali",
						data : "zybusername=" + name,
						//dataType : "json",
						//contentType : "application/json",
						success : function(data) {
							//alert(data)

							if (data == "YES") {

								$("#resultname").html("该账号可以注册").css("color",
										"green");
							} else if (data == "NO") {

								$("#resultname").html("该账号已存在，请重新输入").css(
										"color", "red");
							} else if (data == "NULL") {

								$("#resultname").html("账号为空，请输入").css("color",
										"red");
							}
						}
					});
				});

		$

	});

</script>
</head>
<body>

	<div class="container">
		<div class="jumbotron well">
			<h3>在线图书</h3>
			<p>系统后台</p>
		</div>
		<ul class="breadcrumb">
			<li><a href="#">在线购物系统</a></li>
			<li class="active">用户注册</li>
		</ul>
		<h3>${registerror }</h3>
		<form:form action="/adduser" modelAttribute="user" method="post"
			class="form-horizontal" role="form">
			<div class="form-group">
				<label for="lastname" class="col-sm-2 control-label">账号</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="zybusername"
						id="nameinput">
					<form:errors path="zybusername" cssStyle="color:red"></form:errors>
					<div id="resultname"></div>
				</div>

			</div>

			<div class="form-group">
				<label for="lastname" class="col-sm-2 control-label">密码</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="zybuserpwd"
						id="valiprice">
					<form:errors path="zybuserpwd" cssStyle="color:red"></form:errors>
					<div id="price"></div>
				</div>
			</div>

			<div class="form-group">
				<label for="lastname" class="col-sm-2 control-label">姓名</label>
				<div class="col-sm-10">
					<input type="text" class="form-control" name="zybname"
						id="valiname">
					<form:errors path="zybname" cssStyle="color:red"></form:errors>
					<div id="name"></div>
				</div>
			</div>

			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="submit" class="btn btn-primary" value="添加"> <a
						href="/login" class="btn btn-danger">取消</a>
				</div>
			</div>
		</form:form>
	</div>
</body>
</html>